<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;padding: 0;
        }
        .clock{
            width: 200px;
            height: 200px;
            border: 10px solid #ffe60f;
            border-radius: 50%;
            margin: 0 auto;
            box-shadow: 5px 5px 5px lightgray;
            background-color: #fff;
            position: relative;
        }
        .clock p{
            width: 200px;
            height: 20px;
            /* background-color: aquamarine; */
            line-height: 20px;
            position: absolute;
            top: 90px;
        }
        .clock p span{
            display: block; /* 不改成块标签不支持旋转 */
            width: 20px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            /* background-color: brown; */
        }
        #hour {
            position: absolute;
            transform-origin: center bottom;
            width: 6px;
            height: 50px;
            background-color: #ffe60f;
            left: 97px;
            top: 50px;
        }
        #minute {
            position: absolute;
            transform-origin: center bottom;
            width: 4px;
            height: 70px;
            background-color: #ffe60f;
            left: 98px;
            top: 30px;
        }
        #second {
            position: absolute;
            transform-origin: center bottom;
            width: 2px;
            height: 90px;
            background-color: #ffe60f;
            left: 99px;
            top: 10px;
        }
    </style>
</head>
<body>
    <div class="clock">
        <p><span>1</span></p>
        <p><span>2</span></p>
        <p><span>3</span></p>
        <p><span>4</span></p>
        <p><span>5</span></p>
        <p><span>6</span></p>
        <p><span>7</span></p>
        <p><span>8</span></p>
        <p><span>9</span></p>
        <p><span>10</span></p>
        <p><span>11</span></p>
        <p><span>12</span></p>
        <div id="hour"></div>
        <div id="minute"></div>
        <div id="second"></div>
    </div>
</body>
<script>
    //获取数字
    var ps = document.getElementsByTagName("p");
    //获取三个表针
    var dHour = document.getElementById("hour");
    var dMinute = document.getElementById("minute");
    var dSecond = document.getElementById("second");
    //设置定时器
    var timer = null;
    //设置数字的位置
    function setNums(){
        for (var i=0;i<ps.length; i++){
            ps[i].style.transform = `rotate(${120 + i*30}deg)`;
            //获取p下边的span标签}
            var span = ps[i].getElementsByTagName("span")[0];
             span.style.transform = `rotate(${((120 + i*30)*-1)}deg`;
        }
    }
    setNums();
    //开启定时器
    // timer = setInterval(function(){},1000)   每1000毫秒执行一次function（）
    timer = setInterval(function(){
        changeZhen();
    },1000)
 
    //获取时间戳
    function changeZhen(){
        var date = new Date();
        var s = date.getSeconds();
        var m = date.getMinutes() + s/60;
        var h = date.getHours() + m/60;
 
        dSecond.style.transform = `rotate(${s * 6}deg)`;
        dMinute.style.transform = `rotate(${m * 6}deg)`;
        dHour.style.transform = `rotate(${h * 30}deg)`;
    }
</script>
</html>